const state = {
  sysEnum: {}
}
const mutations = {
  SET_SYS_ENUM: (state, { key, value }) => {
    if (key !== null && key !== "") {
      state.sysEnum[key] = value = value
      // state.sysEnum.push({
      //   key: key,
      //   value: value
      // })
    }
  },
  REMOVE_SYS_ENUM: (state, key) => {
    delete state.sysEnum[key]
    // try {
    //   for (let i = 0; i < state.sysEnum.length; i++) {
    //     if (state.sysEnum[i].key == key) {
    //       state.sysEnum.splice(i, 1)
    //       return true
    //     }
    //   }
    // } catch (e) {
    // }
  },
  CLEAN_SYS_ENUM: (state) => {
    state.sysEnum = {}
    // state.sysEnum = new Array()
  }
}

const actions = {
  // 设置枚举
  setSysEnum({ commit }, data) {
    commit('SET_SYS_ENUM', data)
  },
  // 删除枚举
  removeSysEnum({ commit }, key) {
    commit('REMOVE_SYS_ENUM', key)
  },
  // 清空枚举
  cleanSysEnum({ commit }) {
    commit('CLEAN_SYS_ENUM')
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

